package hsintiao.com.xintiaoAPP.controller;


import hsintiao.com.xintiaoAPP.entity.ArticleType;
import hsintiao.com.xintiaoAPP.service.ArticleTypeService;
import hsintiao.com.xintiaoAPP.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
* 文章类型
* */
@RestController
@RequestMapping("/articleType")
public class ArticleTypeController {
    @Autowired
    private ArticleTypeService articleTypeService;

    /*
    * 获取所有的文章类型(该接口暂未使用)
    * */
    @PostMapping("/getAllType")
    @ResponseBody
    public AjaxResult getAllType(){
        try {
            List<ArticleType> allType = articleTypeService.allType();
            return AjaxResult.me().setCode(200).setSuccess(true).setMessage("成功").setResultObj(allType);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.me().setCode(201).setSuccess(false).setMessage("查询失败");
        }

    }
}
